From: Keir Fraser Date: Wed, 9 Apr 2008 16:49:25 +0000 (+0100) Subject: libxc: Move xg_memalign() into a proper source file, so that it X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~14231^2~34 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks://%22Dat/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22Dat?a=commitdiff_plain;h=1386e66a6eb0203009528069869591152b882702;p=xen.git libxc: Move xg_memalign() into a proper source file, so that it definitely does not leak out of tools/libxc. Return to the ioemu/osdep.c way of checking for posix_memalign() as this works on Solaris. Signed-off-by: Keir Fraser --- diff --git a/tools/libxc/xg_private.c b/tools/libxc/xg_private.c index 37bc587477..02c0ff70a6 100644 --- a/tools/libxc/xg_private.c +++ b/tools/libxc/xg_private.c @@ -8,6 +8,8 @@ #include #include #include +#include +#include #include "xg_private.h" @@ -198,6 +200,22 @@ __attribute__((weak)) return -1; } +void *xg_memalign(size_t alignment, size_t size) +{ +#if defined(_POSIX_C_SOURCE) && !defined(__sun__) + int ret; + void *ptr; + ret = posix_memalign(&ptr, alignment, size); + if (ret != 0) + return NULL; + return ptr; +#elif defined(_BSD) + return valloc(size); +#else + return memalign(alignment, size); +#endif +} + /* * Local variables: * mode: C diff --git a/tools/libxc/xg_private.h b/tools/libxc/xg_private.h index 563585793a..e4dedede6d 100644 --- a/tools/libxc/xg_private.h +++ b/tools/libxc/xg_private.h @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include @@ -177,21 +176,6 @@ int xc_copy_to_domain_page(int xc_handle, uint32_t domid, int pin_table(int xc_handle, unsigned int type, unsigned long mfn, domid_t dom); -/* Grrr portability */ -static inline void *xg_memalign(size_t alignment, size_t size) -{ -#if (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE - 0) >= 600 - int ret; - void *ptr; - ret = posix_memalign(&ptr, alignment, size); - if (ret != 0) - return NULL; - return ptr; -#elif defined(_BSD) - return valloc(size); -#else - return memalign(alignment, size); -#endif -} +void *xg_memalign(size_t alignment, size_t size); #endif /* XG_PRIVATE_H */